
N.optimization1 = N.Class.extend({
    resize: function () {
        // var topheight = $(".container-fluid").height() - $(".content-header").height() - 5;
        var topheight = $('.container-fluid').height() - 20
        var bottomheight = topheight * (1 / 2)
        var boxtop = bottomheight - 120
        var maptop = topheight * (2 / 3) - 60
        var mapbot = topheight * (1 / 3) - 60
        $('.control-size-box').height(boxtop)
        $('.control-size-box-map').height(maptop)
        $('.control-size-box-mapbot').height(mapbot)

        var headheight = $('#table1_wrapper .dataTables_scrollHeadInner').height()
        if (headheight) {
            this.tablbeHeight = boxtop - headheight - 5
            $('#table1_wrapper .dataTables_scrollBody').height(this.tablbeHeight)
        }
        headheight = $('#table2_wrapper .dataTables_scrollHeadInner').height()
        if (headheight) {
            this.tablbeHeight = boxtop - headheight - 5
            $('#table2_wrapper .dataTables_scrollBody').height(this.tablbeHeight)
        }
    },
    pageLoad: function (geography, shiduan, geo_dim, city, area) {
        loading.show()
        if (geography) {
            this.geographyChart(shiduan, geo_dim, city, area)
        } else {
            this.timeChart(shiduan, geo_dim, city, area)
        }
        this.chartTop(shiduan, geo_dim, city, area)
    },
    chartTop: function (shiduan, geo_dim, city, area) {
        loading.show()
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                area: area
            }
        } else {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                city: city,
                area: area
            }
        }
        $.ajax({
            url: getApiPath() + 'wideTableNew/geographyChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                try {
                    $('#high_load_num_lte').text(result[0].high_load_num_lte)// 4G高负荷小区数
                    $('#high_load_ratio_lte').text(result[0].high_load_ratio_lte)// 4G高负荷小区占比
                    $('#mr_coverage_rate').text(result[0].mr_coverage_rate)// MR覆盖率
                    $('#outdoor_poor_coverage_ratio').text(result[0].outdoor_poor_coverage_ratio)// 室分MR弱覆盖占比
                    $('#indoor_poor_coverage_ratio').text(result[0].indoor_poor_coverage_ratio)// 宏站弱覆盖占比
                    $('#video_download_rate').text(result[0].video_download_rate)// 视频下载速率
                    $('#page_display_avg_time').text(result[0].page_display_avg_time)// 页面显示平均时长
                    $('#high_interference_cell_num_tdd').text(result[0].high_interference_cell_num_tdd)// TDD高干扰小区数
                    $('#high_interfer_cell_ratio_tdd').text(result[0].high_interfer_cell_ratio_tdd)// FDD干扰问题小区个数
                    $('#high_interference_cell_num_fdd').text(result[0].high_interference_cell_num_fdd)// TDD干扰小区占比
                    $('#two_low_two_high_singresorate_tdd').text(result[0].two_low_two_high_singresorate_tdd)// 吞字解决率
                    $('#two_low_two_high_singresorate_fdd').text(result[0].two_low_two_high_singresorate_fdd)// 吞字解决率
                } catch (e) {
                    console.log(e)
                }
                loading.hide()
            }
        })
    },
    geographyChart: function (shiduan, geo_dim, city, area) {
        loading.show()
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: '地市',
                time_dim: shiduan,
                area: area
            }
        } else if (geo_dim === '地市' || geo_dim === '区县') {
            param = {
                geo_dim: '区县',
                time_dim: shiduan,
                city: city
            }
        }

        $.ajax({
            url: getApiPath() + 'wideTableNew/geographyChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                // 横坐标
                var xArr = []
                // 纵坐标
                var high_load_num_lte = [], high_load_ratio_lte = [], mr_coverage_rate = [], outdoor_poor_coverage_ratio = [], indoor_poor_coverage_ratio = [], video_download_rate = [], page_display_avg_time = [], high_interference_cell_num_tdd = [], high_interfer_cell_ratio_tdd = [], high_interference_cell_num_fdd = [], two_low_two_high_singresorate_tdd = [], two_low_two_high_singresorate_fdd = []
                $.each(result, function (index, value) {
                    if (value.area === '全量小区') {
                        xArr.push(value.city)
                    } else {
                        xArr.push(value.area)
                    }
                    high_load_num_lte.push(value.high_load_num_lte)
                    high_load_ratio_lte.push(value.high_load_ratio_lte)
                    mr_coverage_rate.push(value.mr_coverage_rate)
                    outdoor_poor_coverage_ratio.push(value.outdoor_poor_coverage_ratio)
                    indoor_poor_coverage_ratio.push(value.indoor_poor_coverage_ratio)
                    video_download_rate.push(value.video_download_rate)
                    page_display_avg_time.push(value.page_display_avg_time)
                    high_interference_cell_num_tdd.push(value.high_interference_cell_num_tdd)
                    high_interfer_cell_ratio_tdd.push(value.high_interfer_cell_ratio_tdd)
                    high_interference_cell_num_fdd.push(value.high_interference_cell_num_fdd)
                    two_low_two_high_singresorate_tdd.push(value.two_low_two_high_singresorate_tdd)
                    two_low_two_high_singresorate_fdd.push(value.two_low_two_high_singresorate_fdd)
                })

                // 4G高负荷小区
                drawColumnCol({
                    id: 'line1',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '4G高负荷小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_load_num_lte,
                            yAxis: 0
                        }, {
                            name: '4G高负荷小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_load_ratio_lte,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: false,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 覆盖类指标
                drawColumnCol({
                    id: 'line2',
                    title: null,
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: 'MR覆盖率(%)',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: mr_coverage_rate
                        }, {
                            name: '室分MR弱覆盖占比(%)',
                            type: 'column',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: indoor_poor_coverage_ratio
                        }, {
                            name: '宏站弱覆盖占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.red,
                            data: outdoor_poor_coverage_ratio
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: false,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 端到端数据业务类指标
                drawColumnCol({
                    id: 'line4',
                    title: null,
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: '视频下载速率(kbps)',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: video_download_rate,
                            yAxis: 0
                        }, {
                            name: '页面显示平均时长(ms)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: page_display_avg_time,
                            yAxis: 1
                        }
                    ],
                    marginTop: 10,
                    marginBottom: 10,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 4G高干扰小区
                drawColumnCol({
                    id: 'line5',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: 'TDD干扰小区',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_interference_cell_num_tdd,
                            yAxis: 0
                        }, {
                            name: 'FDD干扰小区',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.red,
                            data: high_interference_cell_num_fdd,
                            yAxis: 0
                        }, {
                            name: 'TDD干扰小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_interfer_cell_ratio_tdd,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // VOLTE-两低两高及单通吞字解决率
                drawColumnCol({
                    id: 'line6',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: 'TDD吞字解决率(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: two_low_two_high_singresorate_tdd
                        }, {
                            name: 'FDD吞字解决率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: two_low_two_high_singresorate_fdd
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: false,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })
                loading.hide()
            }
        })
    },
    timeChart: function (shiduan, geo_dim, city, area) {
        loading.show()
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                area: area,
                num: shiduan == 'M' ? 6 : 7
            }
        } else {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                city: city,
                area: area,
                num: shiduan == 'M' ? 6 : 7
            }
        }
        $.ajax({
            url: getApiPath() + 'wideTableNew/timeChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                // 横坐标
                var xArr = []
                // 纵坐标
                var high_load_num_lte = [], high_load_ratio_lte = [], mr_coverage_rate = [], outdoor_poor_coverage_ratio = [], indoor_poor_coverage_ratio = [], video_download_rate = [], page_display_avg_time = [], high_interference_cell_num_tdd = [], high_interfer_cell_ratio_tdd = [], high_interference_cell_num_fdd = [], two_low_two_high_singresorate_tdd = [], two_low_two_high_singresorate_fdd = []
                for (var i = result.length - 1; i > -1; i--) {
                    // $.each(result,function (index, value) {
                    var value = result[i]
                    xArr.push(value.starttime.substr(5, 5))
                    high_load_num_lte.push(value.high_load_num_lte)
                    high_load_ratio_lte.push(value.high_load_ratio_lte)
                    mr_coverage_rate.push(value.mr_coverage_rate)
                    outdoor_poor_coverage_ratio.push(value.outdoor_poor_coverage_ratio)
                    indoor_poor_coverage_ratio.push(value.indoor_poor_coverage_ratio)
                    video_download_rate.push(value.video_download_rate)
                    page_display_avg_time.push(value.page_display_avg_time)
                    high_interference_cell_num_tdd.push(value.high_interference_cell_num_tdd)
                    high_interfer_cell_ratio_tdd.push(value.high_interfer_cell_ratio_tdd)
                    high_interference_cell_num_fdd.push(value.high_interference_cell_num_fdd)
                    two_low_two_high_singresorate_tdd.push(value.two_low_two_high_singresorate_tdd)
                    two_low_two_high_singresorate_fdd.push(value.two_low_two_high_singresorate_fdd)
                    // });
                }
                // 4G高负荷小区
                drawColumnCol({
                    id: 'line1',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '4G高负荷小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_load_num_lte,
                            yAxis: 0
                        }, {
                            name: '4G高负荷小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_load_ratio_lte,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: false,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 覆盖类指标
                drawColumnCol({
                    id: 'line2',
                    title: null,
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: 'MR覆盖率(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: mr_coverage_rate
                        }, {
                            name: '室分MR弱覆盖占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: indoor_poor_coverage_ratio
                        }, {
                            name: '宏站弱覆盖占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.red,
                            data: outdoor_poor_coverage_ratio
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: false,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal',
                    Yfloor: 0,
                    Yceiling: 120
                })

                // 端到端数据业务类指标
                drawColumnCol({
                    id: 'line4',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '视频下载速率(kbps)',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: video_download_rate,
                            yAxis: 0
                        }, {
                            name: '页面显示平均时长(ms)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: page_display_avg_time,
                            yAxis: 1
                        }
                    ],
                    marginTop: 10,
                    marginBottom: 10,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 4G高干扰小区
                drawColumnCol({
                    id: 'line5',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: 'TDD干扰小区',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_interference_cell_num_tdd,
                            yAxis: 0
                        }, {
                            name: 'FDD干扰小区',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.red,
                            data: high_interference_cell_num_fdd,
                            yAxis: 0
                        }, {
                            name: 'TDD干扰小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_interfer_cell_ratio_tdd,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // VOLTE-两低两高及单通吞字解决率
                drawColumnCol({
                    id: 'line6',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: 'TDD吞字解决率(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: two_low_two_high_singresorate_tdd
                        }, {
                            name: 'FDD吞字解决率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: two_low_two_high_singresorate_fdd
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: false,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })
                loading.hide()
            }
        })
    }
})
var page = new N.optimization1()

$(function () {
    $(document).on('map:click', function (event, geography, shiduan, geo_dim, map_city, map_area) {
        page.pageLoad(geography, shiduan, geo_dim, map_city, map_area)
    })
})



